Render dark mode toggle in sidebar on all pages (dobon's review)#1763
Open
dobon wants to merge 5 commits intomoment:masterfrom
Open
Render dark mode toggle in sidebar on all pages (dobon's review)#1763dobon wants to merge 5 commits intomoment:masterfrom
dobon wants to merge 5 commits intomoment:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@camoch23 I reviewed your code and it looks pretty good, but I noticed that there is already a "is page scrolled?" feature built into docsify: when you are on the cover page the body element does NOT have a 'sticky' class, and when you are in the docs the body does have a 'sticky' class active.
Because of this I was able to eliminate the IntersectionObserver (which is a cool API that I haven't used before, thanks for introducing it to me), and instead handle the fade-in/fade-out styling in CSS.
For full clarity, my commit duplicates the dark mode toggle so it appears in both the cover (when it exists) and on the sidebar, but the sidebar toggle is opacity:0.0 until body has the 'sticky' class applied (ie: when you have scrolled down past the cover page).
I didn't really want to open a new pull request, but I couldn't figure out how to submit my commit to your branch, so please forgive the duplication.